package com.txcb.lib.base.utils;

import android.text.TextUtils;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author : Lambert
 * date   : 2020/10/29 7:40 PM
 */
public class MacUtil {

    public static String getMac() {
        String mac = null;
        StringBuffer fileData = new StringBuffer(16);

        try {
            BufferedReader reader;
            reader = new BufferedReader(new FileReader("/sys/class/net/wlan0/address"));

            char[] buf = new char[16];
            boolean var5 = false;

            int numRead;
            while ((numRead = reader.read(buf)) != -1) {
                String readData = String.valueOf(buf, 0, numRead);
                fileData.append(readData);
            }

            reader.close();
            mac = fileData.toString();
        } catch (FileNotFoundException var7) {
            var7.printStackTrace();
        } catch (IOException var8) {
            var8.printStackTrace();
        }
        if (TextUtils.isEmpty(mac)) {
            return "uy0iTYfVGkhpC3yi";
        } else {
            mac = mac.replaceAll("\\\\n", "").replaceAll("\\n", "").trim();
            return mac;
        }
    }
}
